/**
 * 
 */
package com.yidin.lsc;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.yidin.entry.MyDynamicEntry;
import com.yidin.entry.NotificationCenterEntry;
import com.yidin.logic.MainService;
import com.yidin.logic.Task;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ListView;
import android.widget.TextView;

/**
 * 消息通知中心
 * @author cola
 *
 */
public class NotificationCenter extends BaseActivity{
	protected ListView myListView;
	protected List<NotificationCenterEntry> netInfos = null;
	protected NotificationCenterAdapter addressListAdapter;
	private Button leftBtn;
	
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.notificationcenter);
		this.init();
	}
	
	@Override
	public void init() {
		// TODO Auto-generated method stub
		((View) findViewById(R.id.outRightBtn)).setVisibility(View.INVISIBLE);
		((TextView) findViewById(R.id.title)).setText("通知中心");
		this.leftBtn = (Button) findViewById(R.id.leftBtn);
		this.myListView = (ListView) 
				findViewById(R.id.myFriendListView);
//		this.netInfos = new ArrayList<NotificationCenterEntry>();
//		NotificationCenterEntry a = new NotificationCenterEntry();
//		a.AccountId = "系统信息";
//		a.Introduction = "你中了一100W";
//		a.Time = "两小时之前";
//		netInfos.add(a);
//		
//		NotificationCenterEntry a2= new NotificationCenterEntry();
//		a2.AccountId = "小明";
//		a2.Introduction = "你在吗？";
//		a2.Time = "两小时之前";
//		netInfos.add(a2);
//		
//		addressListAdapter = new NotificationCenterAdapter(netInfos,this);
//		this.myListView.setAdapter(addressListAdapter);
		this.leftBtn.setOnClickListener(leftOnClickListener);
		//this.myListView.setOnItemClickListener(listOnItemClickListener);
		
		Map obj = new HashMap<String, String>();
		obj.put("AccountId", lscManager.getInstance().myAccount.name);

		showProgress(this);
		Task task = new Task(Task.TASK_USER_NOTIFICATION, obj);
		MainService.AddNewTask(task);
	}

	@Override
	public void refresh(Object... param) {
		// TODO Auto-generated method stub
		this.dismissProgress();
		int task = (Integer) param[0];
		switch (task) {
		case Task.TASK_USER_NOTIFICATION:
			netInfos = (List<NotificationCenterEntry>) param[1];
			if (netInfos == null)
				return;
			addressListAdapter = new NotificationCenterAdapter(netInfos, this);
			myListView.setAdapter(addressListAdapter);
			break;
		}
	}

	@Override
	protected boolean isRouteDisplayed() {
		// TODO Auto-generated method stub
		return false;
	}

	private OnClickListener leftOnClickListener = new OnClickListener() {

		@Override
		public void onClick(View v) {
			// TODO Auto-generated method stub
			finish();
		}

	};
}
